<template>
    <div>
        <h3>登录</h3>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">用户名</td>
                    <td>
                        <input type="text" v-model="querinfo.name">
                    </td>
                </tr>

                <tr>
                    <td align="right">密码</td>
                    <td>
                        <input type="password" v-model="querinfo.pwd">
                    </td>
                </tr>

                <tr>
                    <td align="right"></td>
                    <td>
                        <input type="button" value="登录" @click="login">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref,reactive,onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';
const route=useRoute();
const router=useRouter();
let querinfo:any=reactive({
    name:"",
    pwd:""
})
import { useUserStore } from '@/router/user';
const userstore=useUserStore();


const login=()=>{
    axios({
        method:"get",
        url:"/api/Month/Login",
        params:querinfo
    })
    .then(res=>{
        if(res.data==-1){
            alert('用户名不存在')
        }
        else if(res.data==-2){
            alert('密码错误')
        }
        else{
            alert('ok')
            userstore.information=res.data
            router.push('/yaoshow')
        }
    })
}



</script>

<style scoped></style>